import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";

import {
  TonOrder,
  TonOrderGroup,
  TonOrderGateway,
  RefTonOrderStamp,
  RefTonOrderMedia,
  TonOrderGroupGateway,
  TonOrderMediaGateway,
  TonOrderStampGateway,
} from "qqlx-core";
import { RefTonOrderMediaSchema, RefTonOrderStampSchema, TonOrderGroupSchema, TonOrderSchema } from "qqlx-cdk";

import { PgDao } from "../../lib/dao.pg.id";
import { PgDaoUUid } from "../../lib/dao.pg.uuid";

@Injectable()
export class TonOrderGroupDao extends PgDao<TonOrderGroup> {
  constructor(
    @InjectRepository(TonOrderGroupSchema)
    readonly repo: Repository<TonOrderGroup>,
  ) {
    super({
      repository: repo,
      relations_name: TonOrderGroupGateway.relations,
    });
  }
}

@Injectable()
export class TonOrderDao extends PgDaoUUid<TonOrder> {
  constructor(
    @InjectRepository(TonOrderSchema)
    readonly repo: Repository<TonOrder>,
  ) {
    super({
      repository: repo,
      relations_name: TonOrderGateway.relations,
    });
  }
}

@Injectable()
export class RefTonOrderMediaDao extends PgDao<RefTonOrderMedia> {
  constructor(
    @InjectRepository(RefTonOrderMediaSchema)
    readonly repo: Repository<RefTonOrderMedia>,
  ) {
    super({
      repository: repo,
      relations_name: TonOrderMediaGateway.relations,
    });
  }
}

@Injectable()
export class RefTonOrderStampDao extends PgDao<RefTonOrderStamp> {
  constructor(
    @InjectRepository(RefTonOrderStampSchema)
    readonly repo: Repository<RefTonOrderStamp>,
  ) {
    super({
      repository: repo,
      relations_name: TonOrderStampGateway.relations,
    });
  }
}
